import { createApp } from 'vue'
import pinia from './stores'
import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import './styles/index.scss'
import ElSvg from './components/SvgIcon/ElSvg'
import './permission'
import Category from "@/components/Category/index.vue";
import {useUserInfoStore} from '@/stores/userInfo'
//引入vueEcharts插件
import { vueEcharts } from './plugins/echarts'
import '@/mockServer'

const userInfoStore = useUserInfoStore(pinia)

const app = createApp(App)

//全局注册三级联动组件
app.component("Category", Category);

//注册全局指令
app.directive("has", (el, binding) => {
  //el是按当前绑定自定义指令的DOM
  //binding是当前自定义指令的值
  console.log(binding);
  if (!userInfoStore.userInfo.buttons.includes(binding.value)) {
    el.remove();
  }
});

ElSvg(app)

app.use(pinia)
  .use(router)
  .use(vueEcharts)
  .use(ElementPlus, {
    locale: zhCn,
  })
  .mount('#app')
